package kuang;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author cyt
 * @create 2020-03-07 15:26
 */
public class UnsafeThead {

    public static void main(String[] args) throws InterruptedException {
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < 10000; i++) {
            new Thread(() -> {
/*                synchronized (list) {
                    list.add(Thread.currentThread().getName());
                }*/
                list.add(Thread.currentThread().getName());
            }).start();
        }
        Thread.sleep(3000);
        System.out.println(list.size());
        Set<Object> set = new HashSet<>();
    }
}
/**
 * * 9985
 * <p>
 * Process finished with exit code 0
 */
